package kr.hkit.powerjava.chapter24.work;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class TestMain { //추가,삭제,편집,종료
	//이퀄즈, 컴페얼즈 추가
	public static void main(String[] args) {
		StudentDAO dao = new StudentDAO();
//		dao.insertItem(new Student(1, "김태희", 90, 80, 70));
//		dao.insertItem(new Student(2, "박신혜", 100, 100, 100));
//		dao.insertItem(new Student(3, "김민정", 90, 70, 60));
//		dao.saveList();
		dao.prnItem();
//		dao.insertItem(new Student(4, "아기곰", 70, 90, 50));
//		dao.saveList();

//		dao.loadList();
//		dao.prnItem();
		

//		dao.saveList();

		
//		ArrayList<Student> arList = new ArrayList<>();
//
//		Student std = ;
////		System.out.println(std);
//		Student std2 = new Student(2, "박신혜", 100, 100, 100);
////		System.out.println(std2);
//		
//		arList.add(std);
//		arList.add(std2);
//		
//		
//		ObjectOutputStream oos = null;
//		ObjectInputStream ois = null;
//		
//		BufferedInputStream bis = null;
//		BufferedOutputStream bos = null;
//		
//		try {
//			oos = new ObjectOutputStream(new FileOutputStream("StudentList.dat"));
//			oos.writeObject(arList);
//			oos.flush();
//			//			for(Student temp : arList) {
////				oos.writeObject(temp);
////			}
//			
////			oos.writeObject(std);
////			oos.writeObject(std2);
////			oos.writeObject(arList);
//
//			ois = new ObjectInputStream(new FileInputStream("StudentList.dat"));
//			ArrayList<Student> list = new ArrayList<>();
//
//			list = (ArrayList<Student>)ois.readObject();
//			for(Student st : list) {
//				System.out.println(st);
//			}
////			while(ois.available() != -1) {
////				try {
////					list.add((Student) ois.readObject());
//////					Student std3 = (Student) ois.readObject();
//////					System.out.println(std3);
////				}catch(EOFException e) {
////					break;
////				}
////			}	
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		} catch (IOException e) {
//			e.printStackTrace();
//		} catch (ClassNotFoundException e) {
//			e.printStackTrace();
//		} finally {
//			if(oos != null) try{oos.close();} catch(Exception e) {}
//			if(ois != null) try{ois.close();} catch(Exception e) {}
//		}
	}
}